{
LANG : PASCAL
PROB : plank
ID : phamnamlo2
}

program PLANK;
const
  fi = 'plank.in';
  fo = 'plank.out';
  max = 20000;
var
  a, s : array[0..max] of longint;
  n : longint;
  res : int64;

procedure inp;
var
  i : longint;
begin
  read(n);
  for i := 1 to n do read(a[i]);
end;

procedure swap(x, y : longint);
var
  temp : longint;
begin
  temp := a[x];
  a[x] := a[y];
  a[y] := temp;
end;

procedure sort(l, r : longint);
var
  i, j, k : longint;
begin
  if l >= r then exit;
  i := l;
  j := r;
  k := a[l+random(r-l+1)];
  repeat
    while a[i] > k do inc(i);
    while a[j] < k do dec(j);
    if i <= j then
    begin
      swap(i, j);
      inc(i);
      dec(j);
    end;
  until i >= j;
  sort(i, r); sort(l, j);
end;

procedure process;
var
  i : longint;
begin
  res := 0;
  if n = 1 then exit;
  sort(1, n);
  for i := 1 to n do s[i] := s[i-1] + a[i];
  for i := n downto 2 do res := res + s[i];
end;

procedure out;
begin
  writeln(res);
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);

  inp;
  process;
  out;

  close(output);
  close(input);
end.


20
11 9





2 4 4 5 5

20
11
9
6
2

20
15
10
6

